from random import *
class Player :
    def __init__(self,score=0) -> None:
        self.name = "玩家"
        self.score = score
    def player_action(self,option) :
        if option == 1:
            print(f"{self.name}出石头")
        elif option == 2:
            print(f"{self.name}出剪刀")    
        elif option == 3:
            print(f"{self.name}出布")


class Computer :
    def __init__(self,score=0) -> None:
        self.cname = "电脑"
        self.score = score
    def Computer_action(self,option) :
        if option == 1:
            print(f"{self.cname}出石头")
        elif option == 2:
            print(f"{self.cname}出剪刀")    
        elif option == 3:
            print(f"{self.cname}出布")


class PlayGame :
    count = 0
    def __init__(self) -> None:
        self.Player = Player()
        self.Computer = Computer()
    def show_result(self) :
        print(f"一共进行了{PlayGame.count}场")
        print(f"{self.Player.name}的最终得分为{self.Player.score}")
        print(f"{self.Computer.cname}的最终得分为{self.Computer.score}")
        if self.Player.score > self.Computer.score :
            print("win")
        elif self.Player.score > self.Computer.score :
            print("no win")
        else :
            print("no")
    def start_game(self) :
        print("-"*15,"欢迎进入游戏","-"*15)
        print("1.石头")
        print("2.剪刀")
        print("3.布")
        print("-"*40)
        choose = input("是否开始游戏？(Y/N)")
        while choose == "y" :
            Player_option = input("出招！(选择1,2,3)")
            if Player_option.isdigit() :
                Player_option = int(Player_option)
                self.Player.player_action(Player_option)
            else :
                print("输入有误")
                continue
            Computer_option = randint(1,3)
            self.Computer.Computer_action(Computer_option)
            if Player_option == Computer_option :
                print("平局")
            elif (Player_option == 1 and Computer_option == 2) \
                or (Player_option == 2 and Computer_option == 3) \
                or (Player_option == 3 and Computer_option == 1):
                print("you win")
                self.Player.score += 1
            else :
                print("you no win")
                self.Computer.score += 1
            PlayGame.count += 1
            choose = input("是否进入下一轮(Y/N)")
        self.show_result()
if __name__ == "__main__" :
    game = PlayGame()
    game.start_game()